﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using TrivialPurfuit.Business;

namespace TrivialPurfuit.Presentation.Game
{
    /// <summary>
    /// Interaction logic for BoardView.xaml
    /// </summary>
    public partial class GameBoardView : UserControl
    {

        StateMachine stateMachine;

        public GameBoardView()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            stateMachine = new StateMachine();
            stateMachine.resetGame();

            Presentation.BackDoor.BackDoorView.ShowNow(stateMachine);
        }

        private void RollDie_Click(object sender, RoutedEventArgs e)
        {
            this.stateMachine.userRolledTheDie();
        }

        private void ShowAnswer_Click(object sender, RoutedEventArgs e)
        {
            this.stateMachine.userRequestedTheAnswer();
        }

        private void AnswerCorrect_Click(object sender, RoutedEventArgs e)
        {
            this.stateMachine.userVerifiedTheAnswer(true);
        }

        private void AnswerNotCorrect_Click(object sender, RoutedEventArgs e)
        {
            this.stateMachine.userVerifiedTheAnswer(false);
        }

        private void space_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Rectangle rectangle = (Rectangle)sender;
            GameSpace space = (GameSpace)rectangle.DataContext;

            this.stateMachine.userChoseASpace(space.PositionNumber);

        }
    }
}
